<template>
  <div class="invite_code">
    <div style="display:flex;width:100%;justify-content: space-around;position: absolute;top:50%;left:0;">
      <span style="font-size:16px;">邀请代码:</span>
      <el-input type="text" size="mini" style="width:50%;" v-model="key" placeholder="请输入邀请代码"></el-input>
      <el-button type="primary" @click="onSubmit" size="mini">确认
      </el-button>
    </div>
  </div>
</template>

<script>
  import {oldphoneinfo, verification_yqm} from '../api/api';
  import aestool from '@/utils/aestool.js';
  export default {
    name: "invitation-code",
    data() {
      return {
        key: "",
        userinfo: ''
      }
    },
    mounted() {
      this.userinfo = this.$route.query.info
      console.log('this.userinfo', this.userinfo)
    },
    methods: {
      //生成随机数
      getNum() {
        var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
        var nums = ""
        for (var i = 0; i < 16; i++) {
          var id = parseInt(Math.random() * 61);
          nums += chars[id];
        }
        return nums
      },
      onSubmit() {
        let _this = this;
        let params = {
          invitation: aestool.encrypt(_this.key, '123456asdzxcqwe0'),
        }
        verification_yqm(params).then(res => {
          if (res.Status == 200) {
            this.$router.push({
              path:'/uploadImg_new',
              query:{
                usercode:_this.key
              }
            })
          } else {
            _this.$toast(res.Message)
          }
        })
      },
    }
  }
</script>

<style>

</style>
